package com.goods.business.converter;

import com.goods.common.model.business.InStock;
import com.goods.common.model.business.Product;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Component
public class InStockConverter {

    /**
     * 转voList
     * @param
     * @return
     */
    public static List<InStockVO> converterToInStockVOList(List<InStock> inStocks) {
        List<InStockVO> inStockVOS=new ArrayList<>();
        if(!CollectionUtils.isEmpty(inStocks)){
            for (InStock inStock : inStocks) {
                InStockVO inStockVO = new InStockVO();
                BeanUtils.copyProperties(inStock,inStockVO);
                inStockVOS.add(inStockVO);
            }
        }
        return inStockVOS;
    }
    public static InStockVO converterToInStockVO(InStock inStock){
        InStockVO inStockVO = new InStockVO();
        BeanUtils.copyProperties(inStock,inStockVO);
        return inStockVO;
    }

}
